# -*- coding: UTF-8 -*-
# @description : python
# @Author : zyl
# @Time : 2021/8/27 16:27
# @Remark: 视频监控组视图
from mxsoftpy import View
from index import _
from server.common.VideoManage.VideoMonitor.Group import GroupServer


class GroupAdd(View):

    def post(self):
        """
        添加视频监控组
        """
        try:
            return _('新增成功'), {'group_code': GroupServer().create(**self.request.POST)}
        except Exception as e:
            return str(e)


class GroupList(View):

    def get(self):
        """
        获取组信息
        """

        return '', GroupServer().list(**self.request.GET)


class GroupUpdate(View):

    def get(self):
        """
        更新组
        """
        try:
            return '修改成功', GroupServer().update(**self.request.GET)
        except Exception as e:
            return str(e)


class GroupDelete(View):

    def get(self):
        """
        删除组
        """
        try:
            return '删除成功', {'group_code': GroupServer().delete(**self.request.GET)}
        except Exception as e:
            return str(e)
